<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
include 'inc/PAGE.php';
$p = new PAGE("");

$loginOk = $p->s()->getvar("loginOk");
$username = $p->s()->getvar("username");
$type = $p->s()->getvar("type");

if($loginOk==1  && strlen($username)>0 && $type==LIB) {
    $register = $_POST['register'];
    //$p->t()->debug($register);
    /*
    [0] => category
    [1] => name
    [2] => writer
    [3] => details
    [4] => type
    [5] => isbn
    [6] => copies
    */
    for($i=0;$i<=5;$i++) {
        $register[$i] = htmlspecialchars($register[$i]);
    }
    //$register[3] = $p->t()->cleantext($register[3]);
    //$p->t()->debug($register);
    $sql = "INSERT INTO books(id,category,name,writer,details,type,isbn,copies) VALUES(null,'".$register[0]."','".$register[1]."','".$register[2]."','".$register[3]."','".$register[4]."','".$register[5]."',".$register[6].")";
    //$p->t()->debug($sql);
    $r = $p->db()->insert($sql);
    header("Location: ./ze_book_search.php");
    
}else {
    header("Location: ./index.php");
}
?>
<a href="index.php"><br/>index.php</a>